package com.exam.controller;

import com.exam.pojo.Score;
import com.exam.service.ScoreService;
import com.github.pagehelper.PageInfo;
import jakarta.annotation.Resource;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
public class ScoreController {
    @Resource
    private ScoreService scoreService;
    @GetMapping("/score/{pageNum}/{pageSize}/{studentId}")
    public PageInfo<Score> queryByIdPage(@PathVariable("pageNum") Integer pageNum,
                                         @PathVariable("pageSize") Integer pageSize,
                                         @PathVariable("studentId") Integer studentId){
        return scoreService.queryByStudentIdPage(studentId, pageNum, pageSize);
    }

    @GetMapping("/score/{studentId}/{examId}")
    public boolean isScore(@PathVariable("studentId") Integer studentId,@PathVariable("examId") Integer examId){
        return scoreService.isScore(studentId,examId);
    }
    @PostMapping("/score/add")
    public int add(@RequestBody Score score){
        return scoreService.add(score);
    }

    @GetMapping("/manage/score/{studentId}")
    public List<Score> queryByStudentId(@PathVariable("studentId") Integer studentId){
        return scoreService.queryByStudentId(studentId);
    }

    @GetMapping("/manage/score/exam/{examId}")
    public List<Score> queryByExamId(@PathVariable("examId") Integer examId){
        return scoreService.queryByExamId(examId);
    }
}
